#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Solution
{
public:
    int findMinArrowShots(vector<vector<int>> &points)
    {
        sort(points.begin(), points.end(), [](vector<int> &a, vector<int> &b)
             { return a[1] < b[1]; });
        int n = points.size();
        vector<bool> vis(n, false);
        int arrow = points[0][1];
        int minIndex = 0;
        int count = 0;
        while (n > 0)
        {
            count++;
            for (int i = minIndex; i < points.size(); i++)
            {
                if (points[i][0] <= arrow)
                {
                    if (!vis[i])
                    {
                        vis[i] = true;
                        n--;
                    }
                }
            }
            for (int i = minIndex; i < points.size(); i++)
            {
                if (points[i][0] > arrow && vis[i] == false)
                {
                    minIndex = i;
                    arrow = points[i][1];
                    break;
                }
            }
        }
        return count;
    }
};
int main()
{
    cout << "Code452" << endl;
    Solution s;
    vector<vector<int>> points = {{10, 16}, {2, 8}, {1, 6}, {7, 12}};
    cout << s.findMinArrowShots(points) << endl;
    return 0;
}